import appActionsInit from './appActions'
import mall from './mall'
import GroupInit from './groupInit'

const onHttps = window.location.href.match(/https/)

const config = {
  // pre: 'http://10.10.10.107:8080/game-lobby'
  // pre: 'http://10.10.10.155:8080/game-lobby'
  // pre: 'http://10.10.10.113:8080/game-lobby'
  // pre: onHttps ? 'https://c-c.jiahuagame.com/game-lobby' : 'http://c-c.jiahuagame.com/game-lobby'
  pre: 'http://lefantian.jiahuagame.com/game-lobby'
}
if (global.hostName) {
  config.pre = global.hostName() + '/game-lobby'
  // config.pre = 'https://lefantian-s.jiahuagame.com/game-lobby'
} else if (window.location.hostname.match(/(10\.10\.10)|(localhost)/)) {
  // config.pre = onHttps ? 'https://lefantian.jiahuagame.com/game-lobby' : 'http://lefantian.jiahuagame.com/game-lobby'
  // config.pre = 'https://lefantian-s.jiahuagame.com/game-lobby'
  config.pre = onHttps ? 'https://c-c.jiahuagame.com/game-lobby' : 'http://c-c.jiahuagame.com/game-lobby'
  // config.pre = onHttps ? 'https://10.10.10.107:8080/game-lobby' : 'http://10.10.10.107:8080/game-lobby'
  // config.pre = onHttps ? 'https://10.10.10.155:8080/game-lobby' : 'http://10.10.10.155:8080/game-lobby'
} else if (window.location.hostname.match(/lefantian/)) {
  config.pre = onHttps ? 'https://lefantian.jiahuagame.com/game-lobby' : 'http://lefantian.jiahuagame.com/game-lobby'
} else {
  config.pre = onHttps ? 'https://c-c.jiahuagame.com/game-lobby' : 'http://c-c.jiahuagame.com/game-lobby'
}

// 本地测试版本
// var serverHost_debug = 'http://10.10.10.107:8080';
// var serverHost_test = 'https://lefantian.jiahuagame.com';
// var serverHost_prod = 'https://c-c.jiahuagame.com';
// var serverHost_err = 'https://localhost:8080';

// function hostName() {
//   var address = window.location.host; //浏览器地址
//   var exp_debug = new RegExp("(\\d{1,3}\\.){3}");
//   var exp_test = new RegExp("lefantian.+\\.");
//   var exp_pro = new RegExp("\\.jiahuagame\\.");
//   if (exp_debug.test(address)) return serverHost_debug;
//   else if (exp_test.test(address)) return serverHost_test;
//   else if (exp_pro.test(address)) return serverHost_prod;
//   return serverHost_err;
// }
// config.pre = hostName() + '/game-lobby';

const allActions = {
  appActions: appActionsInit(config),
  mall: mall(config),
  groupActions: GroupInit(config)
}

global.config = config

export default allActions